package com.yunxi.vip.pojo;

import com.alibaba.fastjson.JSONArray;
import com.yunxi.dealer.pojo.PartnerInvoiceVO;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by chenmeng on 2019/9/6.
 */
@Data
public class VipVO implements Serializable {
    @ApiModelProperty(value = "客户id")
    private String vipId;

    @ApiModelProperty(value = "客户名称")
    private String vipName;

    @ApiModelProperty(value = "客户类型")
    private Integer vipType;

    @ApiModelProperty(value = "统一信用代码")
    private String certNo;

    @ApiModelProperty(value = "联系人")
    private String linkman;

    @ApiModelProperty(value = "联系人电话")
    private String phone;

    @ApiModelProperty(value = "详细地址")
    private String vipAddr;

    @ApiModelProperty(value = "渠道商")
    private String partnerCode;

    @ApiModelProperty(value = "区域")
    private String region;

    public void setSortColumn(String sortColumn) {
        this.sortColumn = sortColumn.replaceAll("[A-Z]", "_$0").toLowerCase();
    }

    private String sortColumn;
    private String sortOrder;
    private String provinceCode;
    private String cityCode;
    private String regionCode;
    private String provinceName;
    private String cityName;
    private String regionName;
    private String vipTypeCn;
    private String persons;
    private String vipNo;
    private String memo;
    private String banks;
    private String postalCode;
    private String partnerCodeNot;

    private List<VipPersonVO> personList = new ArrayList<VipPersonVO>();

    private List<PartnerInvoiceVO> bankList = new ArrayList<PartnerInvoiceVO>();

    public void setPersons(String persons) {
        this.persons = persons;
        if(StringUtils.isNotEmpty(persons)){
            personList = JSONArray.parseArray(persons,VipPersonVO.class);
        }
    }

    public void setBanks(String banks) {
        this.banks = banks;
        if(StringUtils.isNotEmpty(banks)){
            bankList = JSONArray.parseArray(banks,PartnerInvoiceVO.class);
        }
    }
}
